import request from "@/utils/request";

const baseUrl = '/portal/componentHub';

// 查询
export function getComponentHubList() {
    return request({
        url: `${baseUrl}/listAll`,
        method: 'GET',
    });
}

// 上传
export function uploadComponentHub(file: File) {
    const formData = new FormData();
    formData.append('file', file);
    return request({
        url: `${baseUrl}/uploadComponentHub`,
        method: 'POST',
        data: formData,
    });
}

// 卸载
export function uninstall(data: componentHubList) {
    return request({
        url: `${baseUrl}/uninstall?name=${data}`,
        method: 'GET',
    });
}

// 启用
export function install() {
    return request({
        url: `${baseUrl}/install`,
        method: 'GET',
    });
}


// 查询已启用的
export function listEnable() {
    return request({
        url: `${baseUrl}/listEnable`,
        method: 'GET',
    });
}

// 新增布局
export function layoutAdd(data: any) {
    return request({
        url: `/portal/layout`,
        method: 'POST',
        data: data,
    });
}

// 修改布局
export function layoutPut(data: any) {
    return request({
        url: `/portal/layout`,
        method: 'PUT',
        data,
    });
}


// 查询布局
export function getLayout() {
    return request({
        url: `/portal/layout/list`,
        method: 'GET',
    });
}

// 设置默认布局
export function allDefaultId(id: string) {
    return request({
        url: `/portal/layout/allDefault/${id}`,
        method: 'GET',
    });
}

// 查询设置默认布局
export function getAllDefaultTem() {
    return request({
        url: `/portal/layout/getAllDefault`,
        method: 'GET',
    });
}

